// Bristleback plugin - Copyright (c) 2010 bristleback.googlecode.com
// ---------------------------------------------------------------------------
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published by the
// Free Software Foundation; either version 3 of the License, or (at your
// option) any later version.
// This library is distributed in the hope that it will be useful,
// but without any warranty; without even the implied warranty of merchantability
// or fitness for a particular purpose.
// You should have received a copy of the GNU Lesser General Public License along
// with this program; if not, see <http://www.gnu.org/licenses/lgpl.html>.
// ---------------------------------------------------------------------------
package pl.bristleback.server.bristle.actions;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

/**
 * Annotation defines the name of action and user required rights set.
 * All action classes, to be seen by a controller, must be marked with this annotation.
 * Annotated classes are searched and processed at plugin start by {@link pl.bristleback.server.bristle.config.ActionAnnotationsProcessor} implementation.
 * Plugin can use default or user processor implementation (specified in config file, see {@link pl.bristleback.server.bristle.BristlebackServerPlugin}).
 * By default, {@link pl.bristleback.server.bristle.config.PackageActionAnnotationsProcessor} is used.
 * <p/>
 * Created on: 2010-09-03 16:02:45 <br/>
 *
 * @author Wojciech Niemiec
 */
@Target({ElementType.TYPE})
@Retention(java.lang.annotation.RetentionPolicy.RUNTIME)
public @interface AnnotatedRemoteAction {
  /**
   * Action class name.
   * Each action must have unique name.
   *
   * @return action class name.
   */
  String actionName();

  /**
   * Required user rights. When user wants to execute any action, his rights set is checked.
   * Action is performed only if user has every required right.
   *
   * @return required user rights.
   */
  String[] requiredRights() default {};

  /**
   * Indicates whether this action class should be instantiated only once at plugin start or on every request.
   * If action class marked with this annotation is taken from the application context and this parameter is set to false,
   * action class bean should be defined with {@code scope="prototype"}. <br>
   * Default value of isSingleton parameter is true.
   *
   * @return true if this action class should be instantiating only at plugin start, false otherwise.
   */
  boolean isSingleton() default true;
}
